/**
 * Created by chenyong on 2015/7/23.
 */

var request = require('request'),
    config = require('./../config');


getToken: function fromHeaderOrQuerystring (req) {
    if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
        return req.headers.authorization.split(' ')[1];
    } else if (req.query && req.query.token) {
        return req.query.token;
    }
    return null;
}

//当前登录用户的信息
exports.currentuserinfo = function (req,res) {
    var userId = req.user._id
    //var userId = req.cookies.uid;
    var req_panoinfo = {
        url: config.api.rootpath + '/api/users/'+ userId,
        headers: {'Authorization': 'Bearer ' + config.api.token()},
    };
    request(req_panoinfo,function(err,httpResponse,body){
        return res.json(201,JSON.parse(body));
    });
};